﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jalal.Library.Data;
using System.Data.Common;
using System.Data;
using Jalal.Library.Utility;

namespace BCGC.DAL
{
    public class AbusePostData
    {
        public static int CreateAbusePost(string comment, bool isActionTaken, int postID, int userID)
        {
            object id = null;
            DataMiner dataMiner = DataFactory.GetDataMiner();
            DbCommand command = DataFactory.GetCommand();
            command.CommandText = "CSP_CreateAbusePost";
            dataMiner.AddParameter(command, "@Comment", DbType.String,500, ParameterDirection.Input, comment);
            dataMiner.AddParameter(command, "@UserID", DbType.Int32, 0, ParameterDirection.Input, userID);
            dataMiner.AddParameter(command, "@PostID", DbType.Int32, 0, ParameterDirection.Input, postID);
            dataMiner.AddParameter(command, "@IsActionTaken", DbType.Boolean, 0, ParameterDirection.Input, isActionTaken);            
            dataMiner.AddParameter(command, "ReturnValue", DbType.Int32, 0, ParameterDirection.ReturnValue, null);
            dataMiner.Execute(command, out id);

            return (int)CommonUtility.FilterNull(id, typeof(int));
        }



        public static bool UpdateAbusePost(int abusePostID, string comment, bool isActionTaken, int postID, int userID)
        {
            object id = null;
            DataMiner dataMiner = DataFactory.GetDataMiner();
            DbCommand command = DataFactory.GetCommand();
            command.CommandText = "CSP_UpdateAbusePost";
            dataMiner.AddParameter(command, "@AbusePostID", DbType.Int32, 0, ParameterDirection.Input, abusePostID);
            dataMiner.AddParameter(command, "@Comment", DbType.String, 500, ParameterDirection.Input, comment);
            dataMiner.AddParameter(command, "@UserID", DbType.Int32, 0, ParameterDirection.Input, userID);
            dataMiner.AddParameter(command, "@PostID", DbType.Int32, 0, ParameterDirection.Input, postID);
            dataMiner.AddParameter(command, "@IsActionTaken", DbType.Boolean, 0, ParameterDirection.Input, isActionTaken);
            dataMiner.AddParameter(command, "ReturnValue", DbType.Int32, 0, ParameterDirection.ReturnValue, null);
            dataMiner.Execute(command, out id);

            return (bool)CommonUtility.FilterNull(id, typeof(bool));
        }

        public static DataTable GetAbusePostByID(int abusePostID)
        {
            DataMiner dataMiner = DataFactory.GetDataMiner();
            DbCommand command = DataFactory.GetCommand();
            command.CommandText = "CSP_GetAbusePostByID";
            dataMiner.AddParameter(command, "@AbusePostID", DbType.Int32, 0, ParameterDirection.Input, abusePostID);
            return dataMiner.GetListData(command);
        }
    }
}
